package me.jessyan.mvparms.demo.mvp.model;

import com.jess.arms.di.scope.ActivityScope;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.mvp.BaseModel;

import javax.inject.Inject;

import io.reactivex.Observable;
import me.jessyan.mvparms.demo.mvp.contract.MainContract;
import me.jessyan.mvparms.demo.data.api.service.MainService;
import me.jessyan.mvparms.demo.data.entity.TopResponse;
import me.jessyan.mvparms.demo.data.entity.UploadImgEntity;
import me.jessyan.mvparms.demo.data.entity.User;
import okhttp3.MultipartBody;

/**
 * @Author: 海洋
 * @Date: 2018/8/17
 * @Desc:
 */
@ActivityScope
public class MainModel extends BaseModel implements MainContract.Model {


    @Inject
    public MainModel(IRepositoryManager repositoryManager) {
        super(repositoryManager);
    }

    @Override
    public Observable<TopResponse<UploadImgEntity>> uploadImage(MultipartBody.Part imgs) {
        //使用rxcache缓存,上拉刷新则不读取缓存,加载更多读取缓存
        return mRepositoryManager
                .obtainRetrofitService(MainService.class)
                .uploadImage(imgs);
    }

    @Override
    public void onDestroy() {

    }
}
